<?php
    @header("Content-Type:text/html;charset=utf-8");

    @include_once("conn.php"); 
    @include_once("common.php");

    if(!( isset($_POST["username"]) && isset($_POST["pid"]) )){
        paramsErr();
    }
 
    $username = $_POST["username"];
    $pid = $_POST["pid"];

    
    $sql = "delete from  `cart` where username = '$username' and pid='$pid'";
    $result = mysqli_query($conn,$sql);

    $obj = array();
if($result){ 
            $rows = mysqli_affected_rows($conn);// > 0 的整数表示所影响的记录行数。0 表示没有受影响的记录。-1 表示查询返回错误。
            if($rows > 0){
                $obj["status"] = true;
                $obj["msg"] = "删除成功";
            }else{  
                $obj["status"] = false;
                $obj["msg"] = "删除失败,数据未改变";
            }
        }else{
            $obj["status"] = false;
            $obj["msg"] = "sql语句有误";
            $obj["sql"] = $sql;
        }
    echo json_encode($obj);
?>